'''
Created on Dec 7, 2015

@author: JimmyMo
'''
import re

def getRuleProcessor(ruleType, ruleFormula):
    ruleProcessorCls = globals()[ruleType]
    ruleProcessor = ruleProcessorCls(ruleFormula)
    return ruleProcessor    

class RegexRuleProcessor(object):
    def __init__(self, formula):
        self.formula = formula
        self.result = ''
        
    def do_process(self, source):
        pattern = re.compile(self.formula, re.IGNORECASE)
        results = pattern.findall(source)
        self.result = ''.join(results)
        return self.result